************Summary stat******************
set more off
/*
cd V:\PIER_Data\Yating\Data


use ".\account_usetype_parcel_block", clear

*************************Difference between EE vs Non EE hh*************
foreach x in condo mixed_use multi_family residential_other single_family{
	gen `x'=(usetype=="`x'")
}

foreach var in sqft{
	ttest `var' if usetype=="single_family" , by (ee)
	gen norm`var' = (r(mu_2) - r(mu_1))/(sqrt(r(sd_2)^2 + r(sd_1)^2))
}
foreach var in reside pool_yes care median_income density poverty_pop white black asian hispanic prct_pop25_morebachelor prct_owner occupancy_rate age {
	ttest `var', by (ee)
	gen norm`var' = (r(mu_2) - r(mu_1))/(sqrt(r(sd_2)^2 + r(sd_1)^2))
}

estpost sum norm*
estout using W:\CCEP\postdocs\Yating\Energy\Analysis\result\Table2_baseline_comp.out, cells("mean(fmt(3))") label replace

sum reside pool_yes care median_income density poverty_pop white black asian hispanic prct_pop25_morebachelor prct_owner occupancy_rate age 
sum reside pool_yes care median_income density poverty_pop white black asian hispanic prct_pop25_morebachelor prct_owner occupancy_rate age  age if ee==0
sum reside pool_yes care median_income density poverty_pop white black asian hispanic prct_pop25_morebachelor prct_owner occupancy_rate age  if ee==1
sum sqft if usetype=="single_family" 
sum sqft if usetype=="single_family"  & ee==0
sum sqft if usetype=="single_family"  & ee==1

*/
***DIFF between matched non-EE vs. EE (List 3)
use /u/flashscratch/y/yatingch/account_usetype_parcel_block_cons_2010_2014_matchList3_ee1015_Final, clear
duplicates drop accounts_id, force

gen vintage_1950=1 if vintage_id==1
replace vintage_1950=0 if vintage_id!=1&vintage_id!=.
gen vintage_1978=1 if vintage_id==2
replace vintage_1978=0 if vintage_id!=2&vintage_id!=.
gen vintage_1990=1 if vintage_id==3
replace vintage_1990=0 if vintage_id!=3&vintage_id!=.
gen vintage_1990post=1 if vintage_id==4
replace vintage_1990post=0 if vintage_id!=4&vintage_id!=.


foreach var in sqft{
	ttest `var' if usetype=="single_family" , by (ee)
	gen norm`var' = (r(mu_2) - r(mu_1))/(sqrt(r(sd_2)^2 + r(sd_1)^2))
}
foreach var in reside pool_yes care median_income density poverty_pop white black asian hispanic prct_pop25_morebachelor prct_owner occupancy_rate age{
	ttest `var', by (ee)
	gen norm`var' = (r(mu_2) - r(mu_1))/(sqrt(r(sd_2)^2 + r(sd_1)^2))
}
estpost sum norm*
estout using W:\CCEP\postdocs\Yating\Energy\Analysis\result\Table2_baseline_compNEW.out, cells("mean(fmt(3))") label append

**summary of matched non-ee participants
sum reside care pool_yes median_income density poverty_pop white black asian hispanic prct_pop25_morebachelor prct_owner occupancy_rate  x y age if ee==0
sum sqft if usetype=="single_family"  if ee==0


/*
***DIFF between matched non-EE vs. EE (List 1)
use V:\PIER_Data\Yating\Data/account_usetype_parcel_block_cons_2010_2014_matchList1_ee1015_Final, clear
duplicates drop accounts_id, force

gen vintage_1950=1 if vintage_id==1
replace vintage_1950=0 if vintage_id!=1&vintage_id!=.
gen vintage_1978=1 if vintage_id==2
replace vintage_1978=0 if vintage_id!=2&vintage_id!=.
gen vintage_1990=1 if vintage_id==3
replace vintage_1990=0 if vintage_id!=3&vintage_id!=.
gen vintage_1990post=1 if vintage_id==4
replace vintage_1990post=0 if vintage_id!=4&vintage_id!=.

foreach var in sqft reside pool_yes care median_income density poverty_pop white black asian hispanic prct_pop25_morebachelor prct_owner occupancy_rate x y age {
	ttest `var', by (ee)
	gen norm`var' = (r(mu_2) - r(mu_1))/(sqrt(r(sd_2)^2 + r(sd_1)^2))
}
estpost sum norm*
estout using W:\CCEP\postdocs\Yating\Energy\Analysis\result\Table2_baseline_comp.out, cells("mean(fmt(3))") label append

***DIFF between matched non-EE vs. EE (List 2)
use V:\PIER_Data\Yating\Data/account_usetype_parcel_block_cons_2010_2014_matchList2_ee1015_Final, clear
duplicates drop accounts_id, force

gen vintage_1950=1 if vintage_id==1
replace vintage_1950=0 if vintage_id!=1&vintage_id!=.
gen vintage_1978=1 if vintage_id==2
replace vintage_1978=0 if vintage_id!=2&vintage_id!=.
gen vintage_1990=1 if vintage_id==3
replace vintage_1990=0 if vintage_id!=3&vintage_id!=.
gen vintage_1990post=1 if vintage_id==4
replace vintage_1990post=0 if vintage_id!=4&vintage_id!=.

foreach var in sqft reside pool_yes care median_income density poverty_pop white black asian hispanic prct_pop25_morebachelor prct_owner occupancy_rate x y age {
	ttest `var', by (ee)
	gen norm`var' = (r(mu_2) - r(mu_1))/(sqrt(r(sd_2)^2 + r(sd_1)^2))
}
estpost sum norm*
estout using W:\CCEP\postdocs\Yating\Energy\Analysis\result\Table2_baseline_comp.out, cells("mean(fmt(3))") label append

sum reside care pool_yes median_income density poverty_pop white black asian hispanic prct_pop25_morebachelor prct_owner occupancy_rate  x y age if ee==0

sum sqft median_income density poverty_pop white black asian hispanic prct_pop25_morebachelor prct_owner occupancy_rate reside x y age care pool_yes
*/


